<?php
/**
 * Edit Test page view
 *
 * Страница добавление/ редактирования тестов системы тестирования
 *
 * @package zfhrtool
 * @subpackage View
 */
$this->headTitle($this->translate('[LS_PAGE_TITLE_TESTS]'));
?>
<script type="text/javascript" language="javascript">
<!--
//<![CDATA[
	function SetAction(action)
	{

		var form = document.getElementById('questionForm');
		form.formAction.value = action;
		return true;
	}
//]]>
-->
</script>

<div id="main">
    <div class="menu-h f-right">
    <ul>
        <li><a href="<?=$this->url(array('controller' => 'index', 'action' => 'index'), null, true)?>">Главная</a></li>
        <li><a href="<?=$this->url(array('controller' => 'test', 'action' => 'index'), null, true)?>">Тесты</a></li>
        <li><a href="<?=$this->url(array('controller' => 'category', 'action' => 'index'), null, true)?>">Категории тестов</a></li>
        <?php if ( isset( $this->testId ) ):?>
        <li><a href="<?=$this->url(array('controller' => 'questioncategory', 'action' => 'index'))?>">Категории вопросов</a></li>
        <?php endif;?>
        <li><a href="<?=$this->url(array('controller' => 'question', 'action' => 'edit', 'testId' => $this -> testId))?>">Добавить вопрос</a></li>
    </ul>
    </div>
	<h1 class="title" style="display:inline; border:0">Тесты : добавление/редактирование</h1>
        <?php echo $this -> objForm; ?>

        Список вопросов теста :
        <table cellpadding="0" cellspacing="0"  class="tablesorter">
        <thead>
        	<tr class="head">
                <th>№</th>
                <th>Текст вопроса</th>
                <th>Вес вопроса</th>
                <th>Категория вопроса</th>
                <th>К-во вариантов ответов</th>
                <th>К-во верных оветов</th>
                <th class="action">Действия</th>
            </tr>
        </thead>
        <tbody>
<?php $i = 1; if (!empty($this -> arrQuestion)): ?>
    <?php foreach ($this -> arrQuestion as $question): ?>
            <tr class="item_row">
                <td><?php echo $this->escape( $question['tq_sort_index'] ); ?></td>
                <td><?php echo $this->escape( $question['tq_text'] ); ?></td>
                <td><?php echo $this->escape( $question['tq_weight'] );?></td>
                <td><?php if ( isset( $question['tqc_id'] )): ?>
                        <?php echo $this->escape( $this->arrQuestionCategories[ $question['tqc_id'] ] )?>
                    <?php endif;?>
                </td>
                <td><?php echo $this->escape( $question['tq_answer_amount'] ); ?></td>
                <td><?php echo $this->escape( $question['tq_right_answers_amount'])?></td>
                <td class="action">
                    <a href="<?php echo $this -> url ( array ( 'controller' => 'question', 'action' => 'edit', 'testId' => $this -> testId, 'questionId' => $question['tq_id'] ) ); ?>"><?php echo $this->translate('[LS_LINK_EDIT]'); ?></a><br />
                    <a href="<?php echo $this -> url ( array ( 'controller' => 'question', 'action' => 'remove', 'testId' => $this -> testId, 'questionId' => $question['tq_id'] ) ); ?>" onClick="return confirm('<?php echo $this->translate('[LS_LINK_REMOVE_CONFIRMATION]'); ?> \' <?php echo $this->escape( $question['tq_text'] ); ?>\'');"><?php echo $this->translate('[LS_LINK_REMOVE]'); ?></a><br />
                    <?php if ( $i > 1 ): ?><a href="<?php echo $this -> url ( array ( 'controller' => 'question', 'action' => 'up', 'testId' => $this-> testId, 'questionId' => $question['tq_id'] ) ); ?>"><?php echo $this->translate('[LS_LINK_UP]'); ?></a><br /><?php endif;?>
                    <?php if ( $i < sizeof( $this -> arrQuestion ) ): ?><a href="<?php echo $this -> url ( array ( 'controller' => 'question', 'action' => 'down', 'testId' => $this -> testId, 'questionId' => $question['tq_id'] ) ); ?>"><?php echo $this->translate('[LS_LINK_DOWN]'); ?></a><br /><?php endif;?>
                </td>
            </tr>
    <?php $i++; endforeach; ?>
<?php else: ?>
            <tr class="item_row">
                <td></td>
                <td colspan="5">нет вопросов</td>
            </tr>
<?php endif;?>
		</tbody>
        </table>
</div>